<?php
/**
* 名称：主页控制器。
* 描述：主页的控制响应程式。
*/
final class Controller_Index extends Controller{
    /**
    * 公共数据标量。
    * @access  private
    * @var     array
    * @default array()
    */
    protected $data=array();

    /**
    * 描述：入口程式。
    * @access protected
    * @return void
    */
    protected function Main(){
        $this->bannerSlide();
        $this->newsTrade();
        $this->newsCompany();
        self::$Template->Assign('data',$this->data);
        self::$Template->Display('index.html');
    }

    /**
    * 描述：横幅幻灯片数据绑定。
    * @access private
    * @return void
    */
    private function bannerSlide(){
        $this->data['bannerSlide']=self::$Database->GetAll(
            'SELECT * FROM '.self::$Database->Table('slide').' WHERE id in(1,2,3,4,9) ORDER BY ID ASC'
        );
    }

    /**
    * 描述：行业新闻数据绑定。
    * @access private
    * @return void
    */
    private function newsTrade(){
        $this->data['newsTrade']=self::$Database->GetAll(
            'SELECT * FROM '.self::$Database->Table('news').' WHERE class=2 ORDER BY ID DESC LIMIT 0,5'
        );
    }

    /**
    * 描述：公司新闻数据绑定。
    * @access private
    * @return void
    */
    private function newsCompany(){
        $this->data['newsCompany']=self::$Database->GetAll(
            'SELECT * FROM '.self::$Database->Table('news').' WHERE class=1 ORDER BY ID DESC LIMIT 0,5'
        );
    }

    /**
    * 描述：绑定横幅幻灯片数据。
    * @access protected
    * @return void
    */
    protected function flashSlide(){
        $data=self::$Database->GetAll('SELECT * FROM '.self::$Database->Table('slide').' WHERE id in(5,6) ORDER BY ID ASC'); //,7,8
        $xml='<?xml version="1.0" encoding="utf-8"?>';
        $xml.='<bcaster autoPlayTime="3">';
        foreach ($data as $row) {
            $xml.='<item item_url="/data/000/unclassified/'.$row['picture'].'" link="'.$row['link'].'"></item>';
        }
        $xml.='</bcaster>';
        //~
        header("Content-type:text/xml");
        echo $xml;
    }
}